package com.example.dingtalkwebproject.service;

import com.aliyun.tea.TeaException;

public class Sample {
    public static com.aliyun.dingtalkoauth2_1_0.Client  createClient() throws Exception {
        com.aliyun.teaopenapi.models.Config  config = new com.aliyun.teaopenapi.models.Config();
        config.protocol  = "https";
        config.regionId  = "central";
        return new com.aliyun.dingtalkoauth2_1_0.Client(config);
    }

    public static void main(String[] args) throws Exception {
        try {
            com.aliyun.dingtalkoauth2_1_0.Client  client = createClient();
            com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest  request =
                    new com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest()
                            .setAppKey("dingr5dyeyzzcyfltidd")
                            .setAppSecret("_JDykD5CF7TkgFGc_af6cDYk5X-4GilGXyFC6cj3xg9-Uz6n9cDZZu5ffHeVnAF5");

            com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse  response =
                    client.getAccessToken(request);

            System.out.println("Access  Token: " + response.getBody().getAccessToken());
            System.out.println("Expires  In: " + response.getBody().getExpireIn());


        } catch (TeaException err) {
            System.err.println("TeaException  Error:");
            System.err.println("Code:  " + err.code);
            System.err.println("Message:  " + err.message);
            err.printStackTrace();
        } catch (Exception e) {
            System.err.println("General  Error:");
            e.printStackTrace();
        }
    }
}